package com.xps.charmingshop.view.fragment;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.FragmentTransaction;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.xps.charmingshop.R;
import com.xps.charmingshop.view.activity.ConductActivity;
import com.xps.charmingshop.view.activity.NewsActivity;
import com.xps.charmingshop.view.activity.ShopActivity;
import com.xps.charmingshop.view.base.BaseFragment;
import com.zhy.autolayout.AutoLinearLayout;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import butterknife.Unbinder;


/**
 * Created by MI on 2018/1/10.
 */

public class ListFragment extends BaseFragment {
    @BindView(R.id.Layout)
    AutoLinearLayout Layout;
    @BindView(R.id.layout_News)
    AutoLinearLayout layoutNews;
    Unbinder unbinder;
    @BindView(R.id.Layout_Shop)
    AutoLinearLayout LayoutShop;

    @Override
    protected int getRes() {
        return R.layout.fragment_list;
    }

    @Override
    protected void init(View view) {
        unbinder = ButterKnife.bind(this, view);
    }

    @Override
    protected void setData(View view) {

    }

    @Override
    public void onClick(View v) {

    }

    public void hide() {
        FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
        fragmentTransaction.addToBackStack(null);
        fragmentTransaction.hide(this);
        fragmentTransaction.commit();
    }


    @Override
    public void onDestroyView() {
        super.onDestroyView();
        unbinder.unbind();
    }

    @OnClick({R.id.layout_News, R.id.Layout_List, R.id.Layout_Shop})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.layout_News:
                Intent intent = new Intent(getActivity(), NewsActivity.class);
                intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                getActivity().startActivity(intent);
                break;
            case R.id.Layout_List:
                Intent intent1 = new Intent(getActivity(), ConductActivity.class);
                intent1.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                getActivity().startActivity(intent1);
                break;
            case R.id.Layout_Shop:
                Intent intent2 = new Intent(getActivity(), ShopActivity.class);
                intent2.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                getActivity().startActivity(intent2);
                break;
        }
    }

}
